//
//  TestCollectionPageFlowTableViewCell_3.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2022/3/4.
//  Copyright © 2022 moon. All rights reserved.
//

#import "TestCollectionPageFlowTableViewCell_3.h"

@implementation TestCollectionPageFlowTableViewCell_3

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat space = [self.class allSpace];
        self.pageFlowLayout.interitemSpacing = space;
        self.pageFlowLayout.pagingCellPosition = 0;
    }
    return self;
}
- (void)customLayoutSubviews{
    [super customLayoutSubviews];
    CGFloat space = [self.class allSpace];
    self.pageFlowLayout.pagingBoundsPosition = space/self.collectionView.bounds.size.width;
    [self layoutLineView];
}
+ (CGFloat)allSpace{
    return 10;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView pageFlowLayout:(MKUICollectionViewPageFlowLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    CGFloat space = [self.class allSpace];
    return UIEdgeInsetsMake(space, space, space, 0);
}
- (CGSize)collectionView:(UICollectionView *)collectionView pageFlowLayout:(MKUICollectionViewPageFlowLayout *)collectionViewLayout itemSizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat space = [self.class allSpace];
    CGRect bounds = collectionView.bounds;
    CGSize size = bounds.size;
    size.height -= space*2;
    size.width = (bounds.size.width-2*space-space)*2.0/3.0;
    return size;
}

@end
